<?php

namespace App\Http\Requests\Business;

use Illuminate\Foundation\Http\FormRequest;

class MaterialRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'year' => 'required|numeric',
            'material' => 'required|max:100',
            'material_desc' => 'required|max:100',
            // 'category_small_id' => 'exists:category_small,id',
            // 'category_big_id' => 'exists:category_big,id',
            // 'category_contract_id' => 'exists:category_contract,id',
            // 'category_key_product_id' => 'exists:category_key_product,id',
        ];
        switch (request()->method) {
            case 'POST':
                break;
            case 'PUT':
                break;
            default:
                break;
        }

        return $rules;
    }

    public function messages()
    {
        return [
            'year.required' => '请选择年度！',
            'year.numeric' => '年度数据为数字格式！',
            'material.required' => '请输入物料编码！',
            'material.max' => '物料编码长度最大为100个字符！',
            'material_desc.required' => '请输入物料描述！',
            'material_desc.max' => '物料描述长度最大为100个字符！',
            'category_small_id.exists' => '请选择统计用细分类！',
            'category_big_id.exists' => '请选择大分类！',
            'category_contract_id.exists' => '请选择合同大类！',
            'category_key_product_id.exists' => '请选择重点产品分类！',
        ];
    }
}
